<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/limh/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/limh/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/limh/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/limh/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/limh/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/limh/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/limh/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="教程,">










<meta name="description" content="在通常情况下，一个复杂的应用程序会由若干个模块组成，一个模块又会含有多个段。而不同模块的段之间、同一模块的段之间往往存在某种联系，这种联系就要体现在段属性的说明上。 段定义的一般格式如下： 123段名  SEGMENT　[对齐类型]　[组合类型]　[类别]…段名  ENDS 段属性“对齐类型”、“组合类型”和“类别”要按此顺序说明，但这些可选项可根据需要选择书写。如果源程序中不指定某个属性，那么，">
<meta name="keywords" content="教程">
<meta property="og:type" content="article">
<meta property="og:title" content="6.3 段的基本属性">
<meta property="og:url" content="https://tdnr.gitee.io/limh/2015/04/01/asm25/index.html">
<meta property="og:site_name" content="土逗牛肉">
<meta property="og:description" content="在通常情况下，一个复杂的应用程序会由若干个模块组成，一个模块又会含有多个段。而不同模块的段之间、同一模块的段之间往往存在某种联系，这种联系就要体现在段属性的说明上。 段定义的一般格式如下： 123段名  SEGMENT　[对齐类型]　[组合类型]　[类别]…段名  ENDS 段属性“对齐类型”、“组合类型”和“类别”要按此顺序说明，但这些可选项可根据需要选择书写。如果源程序中不指定某个属性，那么，">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-01-21T13:59:48.417Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="6.3 段的基本属性">
<meta name="twitter:description" content="在通常情况下，一个复杂的应用程序会由若干个模块组成，一个模块又会含有多个段。而不同模块的段之间、同一模块的段之间往往存在某种联系，这种联系就要体现在段属性的说明上。 段定义的一般格式如下： 123段名  SEGMENT　[对齐类型]　[组合类型]　[类别]…段名  ENDS 段属性“对齐类型”、“组合类型”和“类别”要按此顺序说明，但这些可选项可根据需要选择书写。如果源程序中不指定某个属性，那么，">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/limh/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://tdnr.gitee.io/limh/2015/04/01/asm25/">





  <title>6.3 段的基本属性 | 土逗牛肉</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans ">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/limh/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">土逗牛肉</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/limh/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/limh/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/limh/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/limh/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/limh/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://tdnr.gitee.io/limh/limh/2015/04/01/asm25/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="土逗牛肉">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/limh/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="土逗牛肉">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">6.3 段的基本属性</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-04-01T20:35:50+08:00">
                2015-04-01
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/limh/categories/汇编教程/" itemprop="url" rel="index">
                    <span itemprop="name">汇编教程</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>在通常情况下，一个复杂的应用程序会由若干个模块组成，一个模块又会含有多个段。而不同模块的段之间、同一模块的段之间往往存在某种联系，这种联系就要体现在段属性的说明上。</p>
<p>段定义的一般格式如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">段名  SEGMENT　[对齐类型]　[组合类型]　[类别]</span><br><span class="line">…</span><br><span class="line">段名  ENDS</span><br></pre></td></tr></table></figure>
<p>段属性“对齐类型”、“组合类型”和“类别”要按此顺序说明，但这些可选项可根据需要选择书写。如果源程序中不指定某个属性，那么，汇编程序将使用该属性的缺省值。</p>
<p>程序中的段名可以是唯一的，也可以与其它段同名。在同一模块中，如果有二个段同名，则后者被认为是前段的后续，这样，它们就属同一段。</p>
<p>当同一模块出现二个同名段时，则后者的可选项属性要么与前者相同，要么不写其属性而选用前者的段属性。</p>
<p><strong>例6.13 同段名的作用</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line">DATA1 SEGMENT　;第一个数据段</span><br><span class="line"></span><br><span class="line">         MSG  DB        &quot;Hello, &quot;</span><br><span class="line"></span><br><span class="line">       DATA1  ENDS</span><br><span class="line"></span><br><span class="line">CODE1 SEGMENT　;第一个代码段</span><br><span class="line"></span><br><span class="line">ASSUME　CS:CODE1, DS:DATA1</span><br><span class="line"></span><br><span class="line">      START:  MOV       AX, DATA1</span><br><span class="line"></span><br><span class="line">              MOV       DS, AX</span><br><span class="line"></span><br><span class="line">              MOV       DX, offset MSG</span><br><span class="line"></span><br><span class="line">              MOV       AH, 9</span><br><span class="line"></span><br><span class="line">              INT       21H</span><br><span class="line"></span><br><span class="line">       CODE1  ENDS</span><br><span class="line"></span><br><span class="line">DATA1 SEGMENT　;第二个数据段</span><br><span class="line"></span><br><span class="line">              DB        &quot;World.$&quot;</span><br><span class="line"></span><br><span class="line">       DATA1  ENDS</span><br><span class="line"></span><br><span class="line">CODE1 SEGMENT　;第二个代码段</span><br><span class="line"></span><br><span class="line">              MOV       AX, 4C00H</span><br><span class="line"></span><br><span class="line">              INT       21H</span><br><span class="line"></span><br><span class="line">       CODE1  ENDS</span><br><span class="line"></span><br><span class="line">              END       START</span><br><span class="line"></span><br><span class="line">              END</span><br></pre></td></tr></table></figure>
<p>在上面的例子中，第二个数据段是第一个数据段的后续，汇编程序把它们是合二为一，上述的代码段也如此。</p>
<p>下面，详细说明段属性的含义及其作用。</p>
<h2 id="6-3-1-对齐类型-ALIGN"><a href="#6-3-1-对齐类型-ALIGN" class="headerlink" title="6.3.1 对齐类型(ALIGN)"></a>6.3.1 对齐类型(ALIGN)</h2><p>对齐类型表示当前段对起始地址的要求，连接程序(LINK.EXE)按表6.1的地址格式来定位段的起始地址。在进行段定位时，会根据其定位类型进行定位的，所以，各段之间就有可能出现一些空闲字节，即可能浪费几个字节单元。</p>
<p>段对齐类型PARA是一个适用于所有段类型的对齐类型，它也是缺省的对齐类型。对齐类型BYTE和WORD通常用于数据段的定位，对齐类型DWORD通常用于80386及其以后CPU代码段的定位。</p>
<p><strong>表6.1 段对齐类型与段起始地址之间的对应关系</strong></p>
<table>
<thead>
<tr>
<th>对齐类型</th>
<th>起始地址(二进制)</th>
<th>功能说明</th>
<th>最多的空闲字节数</th>
</tr>
</thead>
<tbody>
<tr>
<td>BYTE</td>
<td>xxxx xxxx xxxx xxxx xxxx</td>
<td>下一个字节地址</td>
<td>0</td>
</tr>
<tr>
<td>WORD</td>
<td>xxxx xxxx xxxx xxxx xxx0</td>
<td>下一个字地址</td>
<td>1</td>
</tr>
<tr>
<td>DWORD</td>
<td>xxxx xxxx xxxx xxxx xx00</td>
<td>下一个双字地址</td>
<td>3</td>
</tr>
<tr>
<td>PARA</td>
<td>xxxx xxxx xxxx xxxx 0000</td>
<td>下一个节地址</td>
<td>15</td>
</tr>
<tr>
<td>PAGE</td>
<td>xxxx xxxx xxxx 0000 0000</td>
<td>下一个页地址</td>
<td>127</td>
</tr>
</tbody>
</table>
<h2 id="6-3-2-组合类型-COMBINE"><a href="#6-3-2-组合类型-COMBINE" class="headerlink" title="6.3.2 组合类型(COMBINE)"></a>6.3.2 组合类型(COMBINE)</h2><p>组合类型是告诉连接程序如何把不同模块中段名相同的段合并在一起。具体的组合类型如下：</p>
<p>NONE 表示当前段在逻辑上独立于其它模块，并有其自己的基地址。NONE是缺省的组合类型。</p>
<p>PUBLIC 表示当前段与其它模块中同段名的PUBLIC类型段组合成一个段。组合的先后次序取决于LINK程序中目标模块排列的次序。在组合时，后续段的起始地址要按其对齐类型进行定位，所以，同名段之间可能有间隔。</p>
<p>COMMON 表示当前段与其它模块中同名段重叠，也就是说，它们的起始地址相同。最终段的长度是同名段的最大长度。由于段覆盖，所以，前一同名段中的初始化数据被后续段的初始数据覆盖掉。</p>
<p>STACK 组合类型STACK表示当前段是堆栈栈，其组合情况与PUBLIC相同。</p>
<p>AT 数值表达式 该数值表达式是当前段所指定的绝对起始地址的段地址。</p>
<h2 id="6-3-3-类别-CLASS"><a href="#6-3-3-类别-CLASS" class="headerlink" title="6.3.3 类别(CLASS)"></a>6.3.3 类别(CLASS)</h2><p>类别是一个由程序员指定的用单引号括起来的字符串。如果一个段没有给出类别，那么，这个段的类别就为空。类别是用于段的分类，连接程序利用该类别来调整同名、同类别的段，并使它们相邻。典型的类别是”Data”和”Code”。如果指定某段的类别是”Code”，那么，该段最好是代码段，这样，有的调试程序(如：CodeView)就可以顺序工作。</p>
<p>例如：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">DATA1  SEGMENT  WORD  PUBLIC   &quot;Data&quot; </span><br><span class="line">… </span><br><span class="line">DATA1  ENDS</span><br></pre></td></tr></table></figure>
<p>上述段定义说明了该段的起始地址是下一个字地址、组合类型为PUBLIC、段类别是”Data”。</p>
<h2 id="6-3-4-段组-GROUP"><a href="#6-3-4-段组-GROUP" class="headerlink" title="6.3.4 段组(GROUP)"></a>6.3.4 段组(GROUP)</h2><p>段组伪指令GROUP是用于把源程序模块中若干个段结合成一个组，并对该段组定义一个段组名。段组伪指令的格式如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">段组名  GROUP  段名[, 段名, ……]</span><br></pre></td></tr></table></figure>
<p>其中：段名之间要用逗号间隔，段名也可以用表达式“SEG 变量”或“SEG 标号”。</p>
<p>下面举例说明段组伪指令的使用方法和作用。</p>
<p><strong>例6.12 段组的作用</strong></p>
<p><strong>方法1：用一个段寄存器对应二个数据段</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">DATA1 SEGMENT ;第一个数据段</span><br><span class="line"></span><br><span class="line">b1 DB　10h</span><br><span class="line"></span><br><span class="line">DATA1 ENDS</span><br><span class="line"></span><br><span class="line">DATA2 SEGMENT ;第二个数据段</span><br><span class="line"></span><br><span class="line">b2 DB　23h</span><br><span class="line"></span><br><span class="line">DATA2 ENDS</span><br><span class="line"></span><br><span class="line">CODE1 SEGMENT</span><br><span class="line"></span><br><span class="line">ASSUME　CS:CODE1, DS:DATA1 ;(1)</span><br><span class="line"></span><br><span class="line">START: MOV AX, DATA1</span><br><span class="line"></span><br><span class="line">MOV DS, AX?;(2)把数据段DATA1的段值赋给段寄存器DS</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line"></span><br><span class="line">MOV BL, b1 ;(3)引用DS来访问DATA1中的变量b1</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line"></span><br><span class="line">ASSUME　DS:DATA2 ;(4)</span><br><span class="line"></span><br><span class="line">MOV AX, DATA2</span><br><span class="line"></span><br><span class="line">MOV DS, AX ;(5)把数据段DATA2的段值赋给段寄存器DS</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line"></span><br><span class="line">MOV AL, b2 ;(6)引用DS来访问DATA2中的变量b2</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line"></span><br><span class="line">CODE1 ENDS</span><br><span class="line"></span><br><span class="line">END START</span><br></pre></td></tr></table></figure>
<p>在上例中，语句(1)说明DS与DATA1建立联系，语句(2)对DS赋值，语句(3)用DS来访问DATA1段的变量名。语句(4)说明DS与DATA2建立联系，语句(5)对DS赋值，语句(6)用DS来访问DATA2段的变量名。</p>
<p>在该例子中，因为只使用一个段寄存器DS来对应二个数据段，所以，需要切换DS的对应关系(如：语句(4))。但我们也可以用段寄存器DS和ES来分别对应段DATA1和DATA2，这样，方法1就可变成方法2。</p>
<p><strong>方法2：用二个段寄存器对应二个数据段</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">DATA1 SEGMENT</span><br><span class="line"></span><br><span class="line">b1 DB　10h</span><br><span class="line"></span><br><span class="line">DATA1 ENDS</span><br><span class="line"></span><br><span class="line">DATA2 SEGMENT</span><br><span class="line"></span><br><span class="line">b2 DB　23h</span><br><span class="line"></span><br><span class="line">DATA2 ENDS</span><br><span class="line"></span><br><span class="line">CODE1 SEGMENT</span><br><span class="line"></span><br><span class="line">ASSUME　CS:CODE1, DS:DATA1, ES:DATA2</span><br><span class="line"></span><br><span class="line">START: MOV AX, DATA1</span><br><span class="line"></span><br><span class="line">MOV DS, AX?;把数据段DATA1的段值赋给段寄存器DS</span><br><span class="line"></span><br><span class="line">MOV AX, DATA2</span><br><span class="line"></span><br><span class="line">MOV ES, AX ;把数据段DATA2的段值赋给段寄存器ES</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line"></span><br><span class="line">MOV BL, b1 ;引用DS来访问DATA1中的变量b1</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line"></span><br><span class="line">MOV AL, b2 ;引用ES来访问DATA2中的变量b2</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line"></span><br><span class="line">CODE1 ENDS</span><br><span class="line"></span><br><span class="line">END START</span><br></pre></td></tr></table></figure>
<p>我们还可以用段组来简化段寄存器的使用，把段DATA1和DATA2组成一个数据段。所以，把方法2再改写成方法3的形式。</p>
<p><strong>方法3：用一个段组组成二个数据段</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">GSEG GROUP DATA1, DATA2 ;把段DATA1和DATA2定义成一个段组</span><br><span class="line"></span><br><span class="line">DATA1 SEGMENT</span><br><span class="line"></span><br><span class="line">b1 DB　10h</span><br><span class="line"></span><br><span class="line">DATA1 ENDS</span><br><span class="line"></span><br><span class="line">DATA2 SEGMENT</span><br><span class="line"></span><br><span class="line">b2 DB　23h</span><br><span class="line"></span><br><span class="line">DATA2 ENDS</span><br><span class="line"></span><br><span class="line">CODE1 SEGMENT</span><br><span class="line"></span><br><span class="line">ASSUME　CS:CODE1, DS:GSEG</span><br><span class="line"></span><br><span class="line">START: MOV AX, GSEG</span><br><span class="line"></span><br><span class="line">MOV DS, AX?;把段组GSEG的段值赋给段寄存器DS</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line"></span><br><span class="line">MOV BL, b1 ;引用DS来访问DATA1中的变量b1</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line"></span><br><span class="line">MOV AL, b2 ;引用DS来访问DATA2中的变量b2</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line"></span><br><span class="line">CODE1 ENDS</span><br><span class="line"></span><br><span class="line">END START</span><br></pre></td></tr></table></figure>
<p>定义段组后，段组内各段所定义的标号和变量，除了与定义它们的段起始点相关外，还与段组的起始点相关。规定如下：</p>
<ul>
<li>如果在ASSUME伪指令中说明段组与段寄存器相对应，那么，有关标号或变量的偏移量就相对于段组起点计算；</li>
<li>如果在ASSUME伪指令中说明段组内的某各段与段寄存器相对应，那么，有关标号或变量的偏移量就相对于该段的起点。</li>
</ul>
<p>所以，在使用段组后，程序员要谨慎使用ASSUME伪指令，并保证段寄存器的值与段组或段相一致。</p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/limh/tags/教程/" rel="tag"># 教程</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/limh/2015/04/01/asm24/" rel="next" title="6.2 程序的基本结构">
                <i class="fa fa-chevron-left"></i> 6.2 程序的基本结构
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/limh/2015/04/01/asm26/" rel="prev" title="6.4 简化的段定义">
                6.4 简化的段定义 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="SOHUCS"></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/limh/images/avatar.jpg" alt="土逗牛肉">
            
              <p class="site-author-name" itemprop="name">土逗牛肉</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/limh/archives/">
              
                  <span class="site-state-item-count">255</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/limh/categories/index.html">
                  <span class="site-state-item-count">8</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/limh/tags/index.html">
                  <span class="site-state-item-count">7</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/limhGeek" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:1591054297@qq.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.jianshu.com/u/f73b243e7cc9" target="_blank" title="简书">
                      
                        <i class="fa fa-fw fa-user-circle-o"></i>简书</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#6-3-1-对齐类型-ALIGN"><span class="nav-number">1.</span> <span class="nav-text">6.3.1 对齐类型(ALIGN)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-3-2-组合类型-COMBINE"><span class="nav-number">2.</span> <span class="nav-text">6.3.2 组合类型(COMBINE)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-3-3-类别-CLASS"><span class="nav-number">3.</span> <span class="nav-text">6.3.3 类别(CLASS)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-3-4-段组-GROUP"><span class="nav-number">4.</span> <span class="nav-text">6.3.4 段组(GROUP)</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">土逗牛肉</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
	var str = GetUrlParam('height');
    if (str === '0'){
		document.getElementById('header').style.display = 'none';
		document.getElementById('comments').style.display = 'none';
		document.getElementById('footer').style.display = 'none';
		document.getElementsByClassName('post-footer').item(0).style.display = 'none'
	}
	
    function GetUrlParam(paraName) {
        var url = document.location.toString();
        var arrObj = url.split("?");

        if (arrObj.length > 1) {
            var arrPara = arrObj[1].split("&");
            var arr;

            for (var i = 0; i < arrPara.length; i++) {
                 arr = arrPara[i].split("=");

                if (arr != null && arr[0] === paraName) {
                    return arr[1];
                }
            }
            return "";
        } else {
            return "";
        }
    }
</script>









  












  
  
    <script type="text/javascript" src="/limh/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/limh/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/limh/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/limh/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/limh/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/limh/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/limh/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/limh/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
